package com.example;

import android.app.AlertDialog;
import android.content.Context;
import android.content.DialogInterface;
import android.view.LayoutInflater;
import android.view.View;
import android.view.ViewGroup;
import android.widget.ArrayAdapter;
import android.widget.TextView;

import androidx.annotation.NonNull;
import androidx.annotation.Nullable;

import com.example.entity.Curriculum;

import java.util.List;

public class CurriculumAdapter extends ArrayAdapter<String[]> {
    private Context mContext;
    private List<String[]> mCurriculumInfo;

    public CurriculumAdapter(@NonNull Context context, @NonNull List<String[]> curriculumInfo) {
        super(context, R.layout.item_curriculum, curriculumInfo);
        mContext = context;
        mCurriculumInfo = curriculumInfo;
    }

    @NonNull
    @Override
    public View getView(int position, @Nullable View convertView, @NonNull ViewGroup parent) {
        if (convertView == null) {
            convertView = LayoutInflater.from(mContext).inflate(R.layout.item_curriculum, parent, false);
        }

        String[] curriculumInfo = mCurriculumInfo.get(position);
        TextView curriculumIdTextView = convertView.findViewById(R.id.tv_curriculum_id);
        TextView curriculumNameTextView = convertView.findViewById(R.id.tv_curriculum_name);

        curriculumIdTextView.setText(curriculumInfo[0]);
        curriculumNameTextView.setText(curriculumInfo[1]);

        // 设置点击事件，弹出显示课程信息的对话框


        return convertView;
    }
}